using System;
using System.Collections.Generic;
using System.Text;
using BitMango;
using HCP.Responses;
using HCP.SimpleJSON;
using JsonFx.Json;

namespace HCP.Requests
{
	public class GetAllShopItems : JobRequest
	{
		public GetAllShopItems(JSONClass json) : base(json)
		{
		}

		public override JobResponse Process()
		{
			string allItemsToString = this.getAllItemsToString();
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			dictionary["items"] = allItemsToString;
			JsonWriterSettings jsonWriterSettings = new JsonWriterSettings();
			jsonWriterSettings.PrettyPrint = false;
			if (this.builder == null)
			{
				this.builder = new StringBuilder();
			}
			else
			{
				this.builder.Length = 0;
			}
			using (JsonWriter jsonWriter = new JsonWriter(this.builder, jsonWriterSettings))
			{
				jsonWriter.Write(dictionary);
			}
			return new StringResponse(this.builder.ToString());
		}

		private string getAllItemsToString()
		{
			ShopItem[] shopItems = Context.UncleBill.shopItems;
			if (this.builder == null)
			{
				this.builder = new StringBuilder();
			}
			else
			{
				this.builder.Length = 0;
			}
			foreach (ShopItem shopItem in shopItems)
			{
				this.builder.Append(shopItem.name);
				this.builder.Append(',');
			}
			return this.builder.ToString();
		}

		public StringBuilder builder;
	}
}
